﻿''' <summary>
''' Provides extension methods to the <see cref="DataRow">DataRow</see> object.
''' </summary>
''' <revisions>
'''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
''' </revisions>
Public Module DataRowExtensions

  ''' <summary>
  ''' Returns the <see cref="Boolean">Boolean</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="Boolean">Boolean</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be <c>False</c>.</remarks>
  ''' <example>
  '''   <para>The following examples get a check/uncheck a checkbox based upon the boolean value returned from the IsProcessed database column.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Check/Unchecked the Is Processed checkbox
  '''       chkIsProcessed.Checked = drCurrentRow.GetBooleanValue("IsProcessed")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Check/Unchecked the Is Processed checkbox
  '''     	chkIsProcessed.Checked = drCurrentRow.GetBooleanValue("IsProcessed");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/2/2008" author="Chad Green" version="1.00.00.000">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetBooleanValue(ByVal input As DataRow, _
                                                ByVal columnName As String) As Boolean
    Return GetBooleanValue(input, columnName, False)
  End Function

  ''' <summary>
  ''' Returns the <see cref="Boolean">Boolean</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="Boolean">Boolean</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="Boolean">Boolean</see> value stored in the specified column.</returns>
  '''   <para>The following examples get a Boolean value from the BooleanColumn in the database specifying that the value should be false if the database value is Null.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the BooleanColumn column in the database
  '''       Dim bValue As Boolean = drCurrentRow.GetBooleanValue("BooleanColumn", False)
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the FirstName column in the database
  '''     	bool bValue = drCurrentRow.GetBooleanValue("BooleanColumn", False);
  '''     
  '''     }
  '''   </code>
  ''' <revisions>
  '''   <revision date="11/2/2008" author="Chad Green" version="1.00.00.000">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetBooleanValue(ByVal input As DataRow, _
                                                ByVal columnName As String, _
                                                ByVal nullValue As Boolean) As Boolean
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(Boolean).ToString Then
      Return Convert.ToBoolean(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

  ''' <summary>
  ''' Returns the <see cref="Byte">Byte</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="Byte">Byte</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be 0.</remarks>
  ''' <example>
  '''   <para>The following examples get a Byte value from the ByteColumn in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the ByteColumn column in the database
  '''       Dim bytValue As Boolean = drCurrentRow.GetBooleanValue("ByteColumn")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the ByteColumn column in the database
  '''     	bool bytValue = drCurrentRow.GetBooleanValue("ByteColumn");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetByteValue(ByVal input As DataRow, _
                                             ByVal columnName As String) As Byte
    Return GetByteValue(input, columnName, 0)
  End Function

  ''' <summary>
  ''' Returns the <see cref="Byte">Byte</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="Byte">Byte</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="Byte">Byte</see> value stored in the specified column.</returns>
  ''' <example>
  '''   <para>The following examples get a Byte value from the ByteColumn in the database specifying that the value should be 10 if the database value is Null.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the ByteColumn column in the database
  '''       Dim bytValue As Boolean = drCurrentRow.GetBooleanValue("ByteColumn", 10)
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the ByteColumn column in the database
  '''     	bool bytValue = drCurrentRow.GetBooleanValue("ByteColumn", 10);
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetByteValue(ByVal input As DataRow, _
                                               ByVal columnName As String, _
                                               ByVal nullValue As Byte) As Byte
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(Byte).ToString Then
      Return Convert.ToByte(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

  ''' <summary>
  ''' Returns the <see cref="DateTime">DateTime</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="DateTime">DateTime</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be a Null (Nothing in Visual Basic) value.</remarks>
  ''' <example>
  '''   <para>The following examples get a DateTime value from the DateTimeColumn in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim dtValue As DateTime = drCurrentRow.GetDateTimeValue("DateTimeColumn")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       DateTime dtValue = drCurrentRow.GetDateTimeValue("DateTimeColumn");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetDateTimeValue(ByVal input As DataRow, _
                                                  ByVal columnName As String) As DateTime
    Return GetDateTimeValue(input, columnName, Nothing)
  End Function

  ''' <summary>
  ''' Returns the <see cref="DateTime">DateTime</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="DateTime">DateTime</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="DateTime">DateTime</see> value stored in the specified column.</returns>
  ''' <example>
  '''   <para>The following examples get a DateTime value from the DateTimeColumn in the database specifying that the value should be equal to right now if the value in the database is Null.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim dtValue As DateTime = drCurrentRow.GetDateTimeValue("DateTimeColumn", Now)
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''     	DateTime dtValue = drCurrentRow.GetDateTimeValue("DateTimeColumn", Now);
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetDateTimeValue(ByVal input As DataRow, _
                                                  ByVal columnName As String, _
                                                  ByVal nullValue As DateTime) As DateTime
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(DateTime).ToString Then
      Return Convert.ToDateTime(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

  ''' <summary>
  ''' Returns the <see cref="Decimal">Decimal</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="Decimal">Decimal</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be 0.</remarks>
  ''' <example>
  '''   <para>The following examples get a Decimal value from the DecimalColumn in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim decValue As Decimal = drCurrentRow.GetDecimalValue("DecimalColumn")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       decimal decValue = drCurrentRow.GetDateTimeValue("DecimalColumn");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetDecimalValue(ByVal input As DataRow, _
                                                  ByVal columnName As String) As Decimal
    Return GetDecimalValue(input, columnName, 0)
  End Function

  ''' <summary>
  ''' Returns the <see cref="Decimal">Decimal</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="Decimal">Decimal</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="Decimal">Decimal</see> value stored in the specified column.</returns>
  ''' <example>
  '''   <para>The following examples get a Decimal value from the DecimalColumn in the database specifying that the value should be 12.75 if the value in the database is Null.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim decValue As Decimal = drCurrentRow.GetDecimalValue("DecimalColumn", 12.75)
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       decimal decValue = drCurrentRow.GetDateTimeValue("DecimalColumn", 12.75);
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetDecimalValue(ByVal input As DataRow, _
                                                  ByVal columnName As String, _
                                                  ByVal nullValue As Decimal) As Decimal
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(Decimal).ToString Then
      Return Convert.ToDecimal(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

  ''' <summary>
  ''' Returns the <see cref="Integer">Integer</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="Integer">Integer</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be 0.</remarks>
  ''' <example>
  '''   <para>The following examples get a Int32 (Integer) value from the Int32Column in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim intValue As Int32 = drCurrentRow.GetDecimalValue("Int32Column")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       Int32 intValue = drCurrentRow.GetDecimalValue("Int32Column");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetInt32Value(ByVal input As DataRow, _
                                                 ByVal columnName As String) As Integer
    Return GetInt32Value(input, columnName, 0)
  End Function

  ''' <summary>
  ''' Returns the <see cref="Integer">Integer</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="Integer">Integer</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="Integer">Integer</see> value stored in the specified column.</returns>
  ''' <example>
  '''   <para>The following examples get a Int32 (Integer) value from the Int32Column in the database specifying that the value should be equal to 1,250,000 if the database value is Null.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim intValue As Int32 = drCurrentRow.GetDecimalValue("Int32Column", 1250000)
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       Int32 intValue = drCurrentRow.GetDecimalValue("Int32Column", 1250000);
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetInt32Value(ByVal input As DataRow, _
                                              ByVal columnName As String, _
                                              ByVal nullValue As Integer) As Integer
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(Integer).ToString Then
      Return Convert.ToInt32(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

  ''' <summary>
  ''' Returns the <see cref="Long">Long</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="Long">Long</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be 0.</remarks>
  ''' <example>
  '''   <para>The following examples get a Int64 (Long) value from the BigIntColumn in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim lngValue As Int64 = drCurrentRow.GetDecimalValue("BigIntColumn")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       Int64 lngValue = drCurrentRow.GetDecimalValue("BigIntColumn");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetInt64Value(ByVal input As DataRow, _
                                              ByVal columnName As String) As Long
    Return GetInt64Value(input, columnName, 0)
  End Function

  ''' <summary>
  ''' Returns the <see cref="Long">Long</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="Long">Long</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="Long">Long</see> value stored in the specified column.</returns>
  ''' <example>
  '''   <para>The following examples get a Int64 (Long) value from the BigIntColumn in the database specifying that the value should be equal to 4,500,000,000 if the database value is Null.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim lngValue As Int64 = drCurrentRow.GetDecimalValue("BigIntColumn", 4500000000)
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       Int64 lngValue = drCurrentRow.GetDecimalValue("BigIntColumn", 4500000000);
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetInt64Value(ByVal input As DataRow, _
                                              ByVal columnName As String, _
                                              ByVal nullValue As Long) As Long
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(Long).ToString Then
      Return Convert.ToInt64(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

  ''' <summary>
  ''' Returns the <see cref="Short">Short</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="Short">Short</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be 0.</remarks>
  ''' <example>
  '''   <para>The following examples get a Int16 (Short) value from the SmallIntColumn in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim shtValue As Int16 = drCurrentRow.GetDecimalValue("SmallIntColumn")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       Int16 shtValue = drCurrentRow.GetDecimalValue("SmallIntColumn");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetInt16Value(ByVal input As DataRow, _
                                              ByVal columnName As String) As Short
    Return GetInt16Value(input, columnName, 0)
  End Function

  ''' <summary>
  ''' Returns the <see cref="Short">Short</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="Short">Short</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="Short">Short</see> value stored in the specified column.</returns>
  ''' <example>
  '''   <para>The following examples get a Int16 (Short) value from the SmallIntColumn in the database specifying that the value should be equal to 500 if the database value is Null.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim shtValue As Int16 = drCurrentRow.GetDecimalValue("SmallIntColumn", 500)
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       Int16 shtValue = drCurrentRow.GetDecimalValue("SmallIntColumn", 500);
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetInt16Value(ByVal input As DataRow, _
                                              ByVal columnName As String, _
                                              ByVal nullValue As Short) As Short
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(Short).ToString Then
      Return Convert.ToInt16(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

  ''' <summary>
  ''' Returns the <see cref="String">String</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <returns>The <see cref="String">String</see> value stored in the specified column.</returns>
  ''' <remarks>If the specified column contains a null, the return value will be a blank string ("").</remarks>
  ''' <example>
  '''   <para>The following examples get a String value from the VarCharColumn in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim strValue As String = drCurrentRow.GetDecimalValue("VarCharColumn")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       string strValue = drCurrentRow.GetDecimalValue("VarCharColumn");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetStringValue(ByVal input As DataRow, _
                                               ByVal columnName As String) As String
    Return GetStringValue(input, columnName, "")
  End Function

  ''' <summary>
  ''' Returns the <see cref="String">String</see> value of the specified column.
  ''' </summary>
  ''' <param name="input">The <see cref="DataRow">DataRow</see> containing the desired data.</param>
  ''' <param name="columnName">Name of the column to retrieve the desired data from.</param>
  ''' <param name="nullValue">The <see cref="String">String</see> value to return if the desired column contains a null value.</param>
  ''' <returns>The <see cref="String">String</see> value stored in the specified column specifying that the value should be equal to "USAAC" if the database value is Null.</returns>
  ''' <example>
  '''   <para>The following examples get a String value from the VarCharColumn in the database.</para>
  '''   <code language="vb">
  '''     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  '''
  '''       ' Get the DataTable the grid is bound to
  '''       Dim dgData As DataGrid = CType(sender, DataGrid)
  '''       Dim tblDatabaseTable As DataTable = CType(dgData.DataSource, DataTable)
  '''       Dim drCurrentRow As DataRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber)
  '''       
  '''       ' Get the value of the DateTimeColumn column in the database
  '''       Dim strValue As String = drCurrentRow.GetDecimalValue("VarCharColumn", "USAAC")
  '''       
  '''       End Sub
  '''   </code>
  '''   <code language="c#">
  '''     private void DataGrid1_Click(object sender, System.EventArgs e)
  '''     {
  '''     
  '''     	// Get the DataTable the grid is bound to
  '''     	DataGrid dgData = (DataGrid)sender;
  '''     	DataTable tblDatabaseTable = (DataTable)dgData.DataSource;
  '''     	DataRow drCurrentRow = tblDatabaseTable.Rows(dgData.CurrentCell.RowNumber);
  '''     
  '''     	// Get the value of the DateTimeColumn column in the database
  '''       string strValue = drCurrentRow.GetDecimalValue("VarCharColumn", "USAAC");
  '''     
  '''     }
  '''   </code>
  ''' </example>
  ''' <revisions>
  '''   <revision date="11/02/2008" author="Chad Green" version="1.0.0.0">Initial Development</revision>
  ''' </revisions>
  <Extension()> Public Function GetStringValue(ByVal input As DataRow, _
                                               ByVal columnName As String, _
                                               ByVal nullValue As String) As String
    If input.IsNull(columnName) = False AndAlso input.Item(columnName).GetType.ToString = GetType(String).ToString Then
      Return Convert.ToString(input.Item(columnName))
    Else
      Return nullValue
    End If
  End Function

End Module